home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus 2004 #2 / Amiga Plus CD - 2004 - No. 02.iso / AmiSoft / Misc / emu / Wzonka-Lad.lha / Wzonka-Lad / src / test / ahi_test.s < prev    next >
Text File  |  2004-01-02  |  6KB  |  249 lines

  1.  
  2. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  3. ;        wzonka-lad the emulator - ahi tester
  4. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  5.  
  6.         incdir    "NDK_3.9:Include/include_i/"
  7.         include    "exec/memory.i"
  8.         include    "dos/dos.i"
  9.         include    "exec/exec_lib.i"
  10.         include    "dos/dos_lib.i"
  11.         include    "libraries/ahi_lib.i"
  12.  
  13.         include    "devices/ahi.i"
  14.         incdir    "wzonka-lad_src:"
  15.  
  16. TRUE        =1
  17. FALSE        =0
  18.  
  19. ExecBase        =4
  20.  
  21. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  22. ;        section    juures,code
  23. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  24.  
  25. ahi_test:    movem.l    d2-d7/a2-a6,-(SP)        ;stack!
  26.         move.l    ExecBase,exec_base        ;cache it locally.
  27.  
  28.         move.l    exec_base,a6
  29.         lea    dos_name,a1
  30.         moveq.l    #39,d0
  31.         jsr    OpenLibrary(a6)
  32.         move.l    d0,dos_base
  33.         beq.w    quit
  34.  
  35. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  36. ;        open ahi
  37. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  38.  
  39.         bsr.w    open_ahi
  40.         move.l    d0,ahi_base
  41.         beq.w    quit
  42.  
  43.         move.l    ahi_base,a6
  44.         sub.l    a0,a0                    ;no tags.
  45.         jsr    AHI_AllocAudioRequestA(a6)
  46.         move.l    d0,ahi_request
  47. ;        beq.w    no_ahi_ctrl
  48.  
  49.         move.l    ahi_base,a6
  50.         move.l    ahi_request,a0
  51.         lea    ahi_requ_tags,a1
  52.         jsr    AHI_AudioRequestA(a6)
  53.  
  54.         move.l    ahi_request,a0
  55.         lea    ahi_alloc_tags,a1
  56.         move.l    ahiam_AudioID(a0),4(a1)            ;use selected mode.
  57.  
  58.         move.l    ahi_base,a6
  59.         lea    ahi_alloc_tags,a1
  60.         jsr    AHI_AllocAudioA(a6)
  61.         move.l    d0,ahi_audio_ctrl
  62.         beq.w    no_ahi_ctrl
  63.  
  64. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  65. ;        load samples
  66. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  67.  
  68.         lea    smpl_info_I,a0
  69.         move.l    #AHIST_M8S,ahisi_Type(a0)        ;type.
  70.         move.l    #smpl_I_bn,ahisi_Address(a0)        ;address.
  71.         move.l    #1024,ahisi_Length(a0)            ;size.
  72.  
  73.         move.l    ahi_base,a6
  74.         moveq.l    #0,d0                    ;sample number.
  75.         move.l    #AHIST_SAMPLE,d1            ;type.
  76.         lea    smpl_info_I,a0                ;info field.
  77.         move.l    ahi_audio_ctrl,a2            ;ctrl.
  78.         jsr    AHI_LoadSound(a6)
  79.  
  80. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  81. ;        play samples
  82. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  83.  
  84.         move.l    ahi_base,a6
  85.         lea    ahi_ctrl_tags_I,a1
  86.         move.l    ahi_audio_ctrl,a2
  87.         jsr    AHI_ControlAudioA(a6)
  88. ;        tst.l    d0
  89. ;        bne.s    ahi_error_I
  90.  
  91.         move.l    ahi_base,a6
  92.         moveq.l    #0,d0                    ;channel.
  93.         move.l    #131000,d1                ;freq.
  94.         moveq.l    #0,d2
  95.         bset    #AHISB_IMM,d2                ;flags.
  96.         move.l    ahi_audio_ctrl,a2
  97.         jsr    AHI_SetFreq(a6)
  98.  
  99.         move.l    ahi_base,a6
  100.         moveq.l    #0,d0                    ;channel.
  101.         moveq.l    #0,d1                    ;sample.
  102.         moveq.l    #1,d2                    ;offset.
  103.         move.l    #0,d3                    ;size (full).
  104.         moveq.l    #0,d4
  105.         bset    #AHISB_IMM,d4                ;flags.
  106.         move.l    ahi_audio_ctrl,a2
  107.         jsr    AHI_SetSound(a6)
  108.  
  109.         move.l    ahi_base,a6
  110.         moveq.l    #0,d0                    ;channel.
  111.         move.l    #$10000,d1                ;volume (max).
  112.         move.l    #$8000,d2                ;pan.
  113.         moveq.l    #0,d3
  114.         bset    #AHISB_IMM,d3                ;flags.
  115.         move.l    ahi_audio_ctrl,a2
  116.         jsr    AHI_SetVol(a6)
  117.  
  118. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  119. ;        quit ahi
  120. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  121.  
  122. jorma:        btst.b    #6,$bfe001
  123.         bne.s    jorma
  124.  
  125.         move.l    ahi_base,a6
  126.         move.l    ahi_request,a0
  127.         jsr    AHI_FreeAudioRequest(a6)
  128.  
  129.         move.l    ahi_base,a6
  130.         move.l    ahi_audio_ctrl,a2
  131.         jsr    AHI_FreeAudio(a6)
  132.  
  133. no_ahi_ctrl:    bsr.w    close_ahi
  134.  
  135. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  136. ;        exit
  137. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  138.  
  139. quit:        move.l    exec_base,a6
  140.         move.l    dos_base,d1
  141.         beq.s    no_dos_base
  142.         move.l    d1,a1
  143.         jsr    CloseLibrary(a6)
  144.  
  145. no_dos_base:    movem.l    (SP)+,d2-d7/a2-a6        ;unstack!
  146.         moveq.l    #0,d0                ;no errors.
  147.         rts
  148.  
  149. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  150. ;        open ahi
  151. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  152.  
  153. open_ahi:    move.l    exec_base,a6
  154.         jsr    CreateMsgPort(a6)
  155.  
  156.         move.l    d0,ahi_port
  157.         beq.b    ahi_error
  158.  
  159.         move.l    d0,a0
  160.         move.l    #AHIRequest_SIZEOF,d0
  161.         jsr    CreateIORequest(a6)
  162.  
  163.         move.l    d0,ahi_ior
  164.         beq.b    ahi_error
  165.  
  166.         lea    ahi_name,a0
  167.         move.l    d0,a1
  168.         clr.w    ahir_Version(a1)        ;all versions are fine!
  169.         move.l    #AHI_NO_UNIT,d0
  170.         moveq.l    #0,d1
  171.         jsr    OpenDevice(a6)
  172.  
  173.         move.l    d0,ahi_device
  174.         bne.b    ahi_error
  175.  
  176.         move.l    ahi_ior,a0
  177.         move.l    IO_DEVICE(a0),d0
  178.         bra.s    ahi_exit
  179.  
  180. ahi_error:    moveq.l    #0,d0
  181. ahi_exit:    rts
  182.  
  183. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  184. ;        close ahi
  185. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  186.  
  187. close_ahi:    move.l    exec_base,a6
  188.         tst.l    ahi_device
  189.         bne.s    ahi_close_nd
  190.  
  191.         move.l    ahi_ior,a1
  192.         jsr    CloseDevice(a6)
  193.  
  194. ahi_close_nd:    move.l    ahi_ior,d0
  195.         beq.s    ahi_no_ior
  196.         move.l    d0,a0
  197.         jsr    DeleteIORequest(a6)
  198.  
  199. ahi_no_ior:    move.l    ahi_port,d0
  200.         beq.s    ahi_no_msg_port
  201.         move.l    d0,a0
  202.         jsr    DeleteMsgPort(a6)
  203.  
  204. ahi_no_msg_port:rts
  205.  
  206. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  207. ;        section    murrr,data
  208. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  209.  
  210. dos_name:    dc.b    "dos.library",0
  211.         even
  212.  
  213. ahi_name:    dc.b    "ahi.device",0
  214.         even
  215.  
  216. exec_base:    dc.l    0
  217. dos_base:    dc.l    0
  218.  
  219. ahi_port:    dc.l    0
  220. ahi_ior:    dc.l    0
  221. ahi_device:    dc.l    0
  222. ahi_audio_ctrl:    dc.l    0
  223. ahi_request:    dc.l    0
  224. ahi_base:    dc.l    0
  225.  
  226. ahi_alloc_tags:    dc.l    AHIA_AudioID,AHI_DEFAULT_ID
  227.         dc.l    AHIA_MixFreq,4410
  228.         dc.l    AHIA_Channels,4
  229.         dc.l    AHIA_Sounds,4
  230.         dc.l    TAG_END,0
  231.  
  232. ahi_requ_tags:    dc.l    AHIR_TitleText,ahi_title
  233.         dc.l    AHIR_InitialMixFreq,4410
  234.         dc.l    AHIR_DoMixFreq,TRUE
  235.         dc.l    TAG_END,0
  236.  
  237. ahi_ctrl_tags_I:dc.l    AHIC_Play,TRUE
  238.         dc.l    TAG_END,0
  239.  
  240. smpl_info_I:    ds.b    AHISampleInfo_SIZEOF
  241.  
  242. ahi_title:    dc.b    "Select a sound driver",0
  243.         even
  244.  
  245. smpl_I_bn:    incbin    "samples/noise.smpl"
  246.         even
  247.  
  248.         END
  249.